package com.ssrs.platform.util;

import java.io.Serializable;

/**
 * @author ssrs
 */
public class ExpiringObject<E> implements Serializable {
    private E value;

    private long lastAccessTime;

    public ExpiringObject() {
    }

    ExpiringObject(E value, long lastAccessTime) {
        if (value == null) {
            throw new IllegalArgumentException("An expiring object cannot be null.");
        }
        this.value = value;
        this.lastAccessTime = lastAccessTime;
    }

    public synchronized long getLastAccessTime() {

        return lastAccessTime;
    }

    public synchronized void setLastAccessTime(long lastAccessTime) {

        this.lastAccessTime = lastAccessTime;
    }

    public E getValue() {
        return value;
    }

    @Override
    public boolean equals(Object obj) {
        return value.equals(obj);
    }

    @Override
    public int hashCode() {
        return value.hashCode();
    }
}
